package com.lxp.modules.gyy.domain;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * Attendance
 *
 * @TableName hr_attendance
 */
@TableName(value = "hr_attendance")
@Data
public class HrAttendance implements Serializable {
    /**
     *
     */
    @TableId
    private Integer id;

    /**
     * Employee
     */
    private Integer employeeId;

    @TableField(exist = false)
    private String empName;
    /**
     * Check In
     */
    private Date checkIn;

    /**
     * Check Out
     */
    private Date checkOut;

    /**
     * Worked Hours
     */
    private Double workedHours;

    /**
     * Created by
     */
    private Integer createUid;

    /**
     * Created on
     */
    private Date createDate;

    /**
     * Last Updated by
     */
    private Integer writeUid;

    /**
     * Last Updated on
     */
    private Date writeDate;

    /**
     * Is Late
     */
    @TableField(value = "is_late")
    private Boolean late;

    /**
     * Is Early
     */
    @TableField(value = "is_early")
    private Boolean early;

    /**
     * 外勤打卡
     */
    private Boolean fieldClock;

    /**
     * Cyrrent Data
     */
    private Date cyrrentData;

    /**
     * Count
     */
    private Integer count;

    /**
     * 类别
     */
    private String attendanceType;

    /**
     * 外勤
     */
    private Date fieldWork;

    /**
     * Work Address
     */
    private String workAddress;

    /**
     * Of Duty Address
     */
    private String ofDutyAddress;

    /**
     * Field Address
     */
    private String fieldAddress;

    /**
     * 上班工作起始
     */
    private Date goHourFrom;

    /**
     * 上班工作截止
     */
    private Date goHourTo;

    /**
     * 下班工作起始
     */
    private Date offHourFrom;

    /**
     * 下班工作截止
     */
    private Date offHourTo;

    /**
     * 是否缺卡
     */
    @TableField(value = "is_lack_card")
    private Boolean lackCard;

    /**
     * Active
     */
    private Boolean active;

    /**
     * Working Time
     */
    private String workingTime;

    /**
     * 上班经度
     */
    private Double goLng;

    /**
     * 上班纬度
     */
    private Double goLat;

    /**
     * 下班经度
     */
    private Double offLng;

    /**
     * 下班纬度
     */
    private Double offLat;

    /**
     * 外勤经度
     */
    private Double fieldLng;

    /**
     * 外勤纬度
     */
    private Double fieldLat;


    public Date getCreateDate() {
        return DateUtil.offsetHour(createDate, 8);
    }


    public Date getCheckIn() {
        if (checkIn != null) {
            return DateUtil.offsetHour(checkIn, 8);
        }
        return checkIn;
    }

    public Date getCheckOut() {
        if (checkOut != null) {
            return DateUtil.offsetHour(checkOut, 8);
        }

        return checkOut;
    }

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}